cmake_minimum_required(VERSION 3.22.1)
project(app_weather VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 设置CMake的编译选项
set(CMAKE_AUTOMOC ON)

# 查找Qt6包
find_package(Qt6 COMPONENTS Widgets Network REQUIRED)

# 查找Vulkan包
find_package(Vulkan REQUIRED)

# 手动指定源文件列表
set(SRC_LIST
    main.cpp
    utils.cpp
    weatherwidget.cpp
    # 在这里添加其他源文件
)

# 添加可执行文件
add_executable(app_weather ${SRC_LIST})

# 链接Qt6库
target_link_libraries(app_weather Qt6::Widgets Qt6::Network)

# 链接Vulkan库
target_link_libraries(app_weather Vulkan::Vulkan)

# 使用 target_compile_features 设置 C++ 标准
target_compile_features(app_weather PRIVATE cxx_std_11)

# 添加包含目录
target_include_directories(app_weather PRIVATE)

# 添加编译选项
target_compile_options(app_weather PRIVATE
    $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wpedantic>
    $<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wpedantic>
    # 如果使用其他编译器，可以在这里添加相应的选项
)

# 添加安装规则
install(TARGETS app_weather DESTINATION bin)

# 添加自定义清理目标
add_custom_target(clean_all
    COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
    COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/CMakeCache.txt
    COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/CMakeFiles
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
